home *** CD-ROM | disk | FTP | other *** search
- /* file: RandomDot.c
- puts random dots in its area
- By MGD
- */
-
- #include "busybox.h"
- #define abs(x) ((x <= 0) ? (-x) : (x))
- #define ThruThreshold 150
-
- /* Guys: It's possible to put some "file-global" data here if you want to share it
- among all the functions in this file. It's up to you if you want */
- static Rect ourRect;
- static int16 numThru;
- static width, height;
-
- void InitRandomDotObj(Rect *drawArea, int16 ID) {
- /* You can put various stuffages here - i.e. load string resources, init a brick
- picture, oop ack. */
-
- ourRect = *drawArea;
- numThru = 0;
- width = ourRect.right;
- height = ourRect.bottom;
- SetRect(&ourRect,0, 0, 500, 500);
-
- } /* InitRandomDotObj */
-
-
-
- void DrawRandomDotObj(int16 ID) {
- static Point whereLast; /* what the last point drawn was */
-
- int16 i, j, z;
-
- if (numThru++ > ThruThreshold) {
- EraseRect(&ourRect);
- numThru = 0;
- }
- MoveTo(whereLast.h, whereLast.v);
- z = Random();
- i = abs(z) % width;
- z = Random();
- j = abs(z) % height;
- LineTo(i,j);
- whereLast.h = i; whereLast.v = j;
- } /* DrawRandomDotObj */
-
-
-
-